package cn.hairui.blog.dao;

import cn.hairui.blog.entity.SRescManage;
import cn.hairui.blog.entity.SRescMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author laoganbu
 * @since 2020-04-08
 */
@Mapper
public interface SRescMenuMapper extends BaseMapper<SRescMenu> {
    @Select("select * from s_resc_menu where resc_id=#{rescId} and use_flag=#{flag} order by order_id asc")
    List<SRescMenu> selectByRescIdUseFlagOrder(String rescId, String flag);

    @Select("select * from(select resc_id as permissionId,resc_name as permissionName,'' as permissionUrl, '0' as pid,order_id as seq,'0' as resType from s_resc_manage order by order_id asc) a " +
            "union all " +
            "select * from(select title as permissionId,order_id as permissionName,href as permissionUrl,resc_id as pid,'' as seq,'1' as rescType  from s_resc_menu  order by order_id asc) b")
    List<Map> listMenu();


    @Select("SELECT * FROM S_RESC_MANAGE WHERE USE_FLAG='Y' ORDER BY ORDER_ID ASC")
    List<SRescManage> listManage();
}
